import React,{ useEffect } from 'react';
import { ApolloProvider } from '@apollo/react-hooks';
import { observer,DataCenter,OneForAllMountPoint } from './data';
import {clientBuilder} from './network';
import {Dimens} from './res';
import App from './App';
import Orientation from 'react-native-orientation';

const TAG = "SRC :: ApolloApp \\ ";


const ApolloApp: () => JSX.Element = () => {

    var MyClient = clientBuilder(DataCenter.User.user?.token ?? "");
    const initial = Orientation.getInitialOrientation();

    useEffect(() => {
        DataCenter.App_setClient(MyClient);
    }, []);

    return (
        <ApolloProvider client={MyClient}>
            <App/>
            <OneForAllMountPoint client={MyClient} />
        </ApolloProvider>
    )
}
export default observer(ApolloApp);

/**
 * Orientation.lockToPortrait();
 * Orientation.addOrientationListener(o => {})
 * Orientation.removeOrientationListener(l）
 *   LANDSCAPE
 *   PORTRAIT
 *   PORTRAITUPSIDEDOWN
 *   UNKNOWN 
 * addSpecificOrientationListener((specificOrientation) => {});
 *   LANDSCAPE-LEFT
 *   LANDSCAPE-RIGHT
 *   PORTRAIT
 *   PORTRAITUPSIDEDOWN
 *   UNKNOWN
 * 
 * API
    lockToPortrait()
    lockToLandscape()
    lockToLandscapeLeft()
    lockToLandscapeRight()
    unlockAllOrientations()
    getOrientation((err, orientation) => {})
    getSpecificOrientation((err, specificOrientation) => {})

 */